Skip to content

feat: display friendly error messages on API failure (closes #34)#53

Closed
Ai-chan-0411 wants to merge 2 commits intoO2sa:mainfrom
Ai-chan-0411:feat/friendly-api-errors
Closed

feat: display friendly error messages on API failure (closes #34)#53
Ai-chan-0411 wants to merge 2 commits intoO2sa:mainfrom
Ai-chan-0411:feat/friendly-api-errors

Conversation

@Ai-chan-0411
Copy link
Copy Markdown
Contributor

Summary

  • Improve API error handling to distinguish between user-not-found (404), rate-limit exceeded (429), network errors (503), and generic failures (500)
  • Replace plain error div with a styled Alert component using AlertCircle icon and descriptive title
  • Pass error prop to CompareForm for inline error display near the input fields
  • Each error message now includes actionable guidance (e.g., "check usernames", "wait a few minutes")

Closes #34

Test plan

  • Enter a non-existent GitHub username → should show "could not be found" message with 404
  • Verify error displays with AlertCircle icon and "Comparison Failed" title
  • Verify error clears when submitting a new valid comparison
  • Verify error shows both in form area and below form

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

@Ai-chan-0411 is attempting to deploy a commit to the osama's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

Thank you for the pull request! ✅

A maintainer will review this soon. Please be patient while we take a look. 🙌

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dev-impact Ready Ready Preview, Comment Apr 11, 2026 11:53pm

Copy link
Copy Markdown
Owner

@O2sa O2sa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error shown twice one in the compare-form and another in the result-dashboard.
And the error that's return from the API when the the username is invalid is:

{"success":false,"error":"Something went wrong. Please try again later."}

Ai-chan-0411 added a commit to Ai-chan-0411/DevImpact that referenced this pull request Apr 11, 2026
- Stop passing error prop to CompareForm component
- Keep single error display in Alert component at page level
- Improves UX by showing error in only one location
- Addresses review feedback from O2sa (O2sa#53)
@Ai-chan-0411
Copy link
Copy Markdown
Contributor Author

Hi @O2sa! Thank you for catching that - you're absolutely right about the duplicate error display.

I've fixed the issue by removing the error prop from the CompareForm component. Now the error message is displayed only once in the Alert component at the page level, which provides a cleaner and more focused user experience.

Key changes:

  • Removed error={error} prop being passed to CompareForm
  • Kept the styled Alert component for displaying errors
  • Error is now shown in exactly one place

The fix is ready in commit Ai-chan-0411@7c3d01a

Let me know if you'd like any adjustments!

Ai-chan-0411 and others added 2 commits April 12, 2026 08:26
- Distinguish between user-not-found (404), rate-limit (429),
  network errors (503), and generic failures (500) in API route
- Return appropriate HTTP status codes for each error type
- Replace plain error div with Alert component using AlertCircle icon
- Pass error prop to CompareForm for inline error display
- Provide actionable guidance in each error message

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…shboard

- Remove duplicate error Alert block from page.tsx (was shown twice)
- Error is now displayed only via CompareForm's error prop
- Improve invalid username detection in API route to handle GraphqlResponseError
  format from @octokit/graphql (catches 'Could not resolve to a User' messages)

Signed-off-by: Ai-chan-0411 (藍) <aoikabu12@gmail.com>
@Ai-chan-0411 Ai-chan-0411 force-pushed the feat/friendly-api-errors branch from b5a27b4 to 93ec162 Compare April 11, 2026 23:27
Copy link
Copy Markdown
Contributor Author

@Ai-chan-0411 Ai-chan-0411 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @O2sa! Here's what I fixed:

  1. Duplicate error display: Removed the second Alert block that was rendering in page.tsx after CompareForm. The error is now shown only once, inside CompareForm via its error prop.

  2. Invalid username showing generic error: Improved the error detection in app/api/compare/route.ts. The @octokit/graphql client throws a GraphqlResponseError with message "Could not resolve to a User with the login of '...'" rather than a simple "User not found". The route now checks for that pattern (and the errors[].type === 'NOT_FOUND' field) so invalid usernames return the friendly 404 message instead of the generic 500.

@O2sa
Copy link
Copy Markdown
Owner

O2sa commented Apr 11, 2026

The error still duplicated and even when the username is invalid it is shown the wrong error!
This PR is take a lot of efforts so I will close is.
Feel free to work on another issues.
Thanks!

@O2sa O2sa closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display friendly error message on API failure

2 participants